package com.iris.live.services.data.repositories;

import com.iris.live.services.data.models.报价精品详细表Model;
import com.iris.live.services.data.models.报价精品详细表ModelPK;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by xiO on 2016/11/7.
 */

public interface 报价精品详细表Repository extends JpaRepository<报价精品详细表Model, 报价精品详细表ModelPK>, JpaSpecificationExecutor<报价精品详细表Model> {


    @Query("select a from 报价精品详细表Model a where a.编号=?1 and a.id=?2")
    报价精品详细表Model findDetailRecordByComboIdsss(int id ,int ids);

    @Query("select sum(a.成本 * a.数量) from 报价精品详细表Model a where a.编号=?1 and a.折后价 >0 ")
    BigDecimal findAfterBuy(int id);

    @Query("select sum(a.成本 * a.数量) from 报价精品详细表Model a where a.编号=?1 and a.折后价 <= 0 ")
    BigDecimal findAfterIsFree(int id);

    /**
     * 根据套餐Id查找
     * @param packageId 套餐编号
     * @return 返回
     */
    @Query("select s from 报价精品详细表Model s where s.id = ?1")
    List<报价精品详细表Model> findByPackageId(String packageId);

}
